$(document).ready(function(){

    $.ajax({
        type: "GET",
        cache:false,
        url: "/proxy/get_links",
        dataType: "json",
        success: function(data){
            if(data.code == 200){

                //遍历处理
                $.each(data.data, function(idx, obj) {
                    //拼接推广链接
                    var html = '<li style="margin:15px 0;border-bottom: 1px solid #0d52a3"><span style="color: #0C0C0C">'+obj.gname+'：</span><span class="exten01">'+obj.url+'</span></li>';
                    var qrcode = new QRCode(document.getElementById("links"), {
                        text: obj.url,
                        width: 128,
                        height: 128,
                        colorDark : "#000000",
                        colorLight : "#ffffff",
                        correctLevel : QRCode.CorrectLevel.H
                    });
                    $('#links').append(html);
                });

            }else{
                //返回错误信息
                var message = '';
                $.each(data.data, function(idx, obj) {
                    message += obj+"<br/>";
                });

                layer.open({
                    content: message,
                    skin: 'msg',
                    time: 3 //2秒后自动关闭
                });
            }
        },
        error:function(data){
            return false;
        }
    });

});